package com.juyu.miliao.common.util;

import java.io.IOException;
import java.nio.charset.Charset;
import org.apache.commons.io.IOUtils;
import org.springframework.core.io.ClassPathResource;

public class JsonLoader {
	private final Class<?> resourceLoadClass;
	
	public JsonLoader(Class<?> resourceLoadClass){
		this.resourceLoadClass = resourceLoadClass;
	}

	public String getJson(String fileName) {
		try {
			return IOUtils.toString(new ClassPathResource(fileName, resourceLoadClass).getInputStream(), Charset.forName("UTF-8"));
		} catch (IOException e) {
			throw new RuntimeException(e);
		}
	}
	
}
